﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Text;
using Maticsoft.DBUtility;
using Utils;
using System.Collections.Specialized;
using Maticsoft.Model;


public partial class WebPage_ajaxPage_YouqingLianjie :SystemBBasePage 
{
    // Fields
    private Friendlink frd = new Friendlink();
    private Maticsoft.BLL. Friendlink friendLink = new Maticsoft.BLL.Friendlink();
    protected int id = 0;
    protected NameValueCollection links = new NameValueCollection();
    protected string tit = "新建";

    // Methods
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.id = Helper.GetInt(base.Request["id"], 0);
        if (!base.IsPostBack)
        {
            if ((base.Request.HttpMethod == "POST") && (base.Request["buttontype"] == "确定"))
            {
                this.frd.Title = Helper.GetString(base.Request["title"], string.Empty);
                this.frd.url = Helper.GetString(base.Request["url"], string.Empty);
                this.frd.Logo = Helper.GetString(base.Request["logo"], string.Empty);
                this.frd.Sort_order = Helper.GetInt(base.Request["sort_order"], 0);
                if (this.id == 0)
                {
                    if (this.friendLink.Add(this.frd) > 0)
                    {
                        base.SetSuccess("添加友情链接成功!");
                        base.Response.Redirect(base.Request.UrlReferrer.AbsoluteUri);
                        base.Response.End();
                    }
                }
                else
                {
                    this.frd.Id = this.id;
                    this.friendLink.Update(this.frd);
                    base.SetSuccess("更新友情链接成功！");
                    base.Response.Redirect(base.Request.UrlReferrer.AbsoluteUri);
                    base.Response.End();
                }
            }
            else
            {
                foreach (Friendlink friendlink in this.friendLink.GetModelList("Id=" + this.id))
                {
                    this.links = Helper.GetObjectProtery(friendlink);
                }
            }
        }
    }

}